/* eslint-disable no-extra-parens */
import { InitModalMethod, ParseModalMethod } from './defination';
/**
 * 设置表单属性
 * @param { Object } form 表单数据
 * @param { Object } workstep cached的ai工作流
 */
export const initModalData = (form = {}, workstep = {}, tts = false) => {
	if (!form || !workstep || !workstep.do) {
		return;
	}
	form.name = workstep.name; //模板标题名字
	form.aiSpeak = workstep.do?.data; // 1
	form.aiSpeakVideo = workstep.do?.video;
	form.waitTime = workstep.after.data?.speechBeginWaitingTimeMS; // 2

	// 智能问答
	form.intelligentReply = JSON.parse(JSON.stringify(workstep.intelligentReply));
	// form['intelligentRepm rlies'] = workstep.intelligentReply.data && JSON.parse(JSON.stringify(workstep.intelligentReply.data));

	// yes
	if (workstep.answer[1]?.after) {
		form.wordsYes = workstep.answer[1]?.do?.data; // 3
		form.wordsYesVideo = workstep.answer[1]?.do?.video;
		form.nextStepYes = workstep.answer[1]?.after?.id;
	} else {
		form.nextStepYes = workstep.answer[1]?.do?.id;
		form.wordsYesVideo = workstep.answer[1]?.do?.video;
	}
	// no
	if (workstep.answer[2]?.after) {
		form.wordsNo = workstep.answer[2]?.do?.data; // 4
		form.wordsNoVideo = workstep.answer[2]?.do?.video;
		form.nextStepNo = workstep.answer[2]?.after?.id;
	} else {
		form.nextStepNo = workstep.answer[2]?.do?.id;
		form.wordsNoVideo = workstep.answer[2]?.do?.video;
	}
	// repeat
	if (workstep.answer[3]?.after) {
		form.repeatAnswers[0].words = workstep.answer[3]?.do?.data; // 5
		form.repeatAnswers[0].wordsVideo = workstep.answer[3]?.do?.video;
	} else if (tts) {
		form.repeatAnswers[0].wordsVideo = workstep.answer[3]?.do?.video;
	}
	if (workstep.repeatErrorRemind?.after) {
		form.repeatAnswers[0].nextStep = workstep.repeatErrorRemind?.after?.id;
		form.repeatAnswers[0].wordsEnd = workstep.repeatErrorRemind?.do?.data; // 7
		form.repeatAnswers[0].wordsEndVideo = workstep.repeatErrorRemind?.do?.video;
	} else {
		form.repeatAnswers[0].nextStep = workstep.repeatErrorRemind?.do?.id;
		form.repeatAnswers[0].wordsEndVideo = workstep.repeatErrorRemind?.do?.video;
	}
	if (form.repeatAnswers[0].nextStep) {
		form.repeatSetting = true;
	}
	form.repeatAnswers[0].wordsTimesMax = workstep.repeatErrorRemind?.maximum; // 9

	// fuzzy
	if (workstep.answer[4]?.after) {
		form.blurAnswers[0].words = workstep.answer[4]?.do?.data; // 5
		form.blurAnswers[0].wordsVideo = workstep.answer[4]?.do?.video;
	} else if (tts) {
		form.blurAnswers[0].wordsVideo = workstep.answer[4]?.do?.video;
	}
	if (workstep.fuzzyErrorRemind?.after) {
		form.blurAnswers[0].nextStep = workstep.fuzzyErrorRemind?.after?.id;
		form.blurAnswers[0].wordsEnd = workstep.fuzzyErrorRemind?.do?.data; // 7
		form.blurAnswers[0].wordsEndVideo = workstep.fuzzyErrorRemind?.do?.video;
	} else {
		form.blurAnswers[0].nextStep = workstep.fuzzyErrorRemind?.do?.id;
		form.blurAnswers[0].wordsEndVideo = workstep.fuzzyErrorRemind?.do?.video;
	}
	if (form.blurAnswers[0].nextStep) {
		form.blurSetting = true;
	}
	form.blurAnswers[0].wordsTimesMax = workstep.fuzzyErrorRemind?.maximum; // 9

	// other
	if (workstep.answer[0]?.after) {
		form.wordsOther = workstep.answer[0]?.do?.data; // 5
		form.wordsOtherVideo = workstep.answer[0]?.do?.video;
	} else if (tts) {
		form.wordsOtherVideo = workstep.answer[0]?.do?.video;
	}
	if (workstep.errorRemind?.after) {
		form.nextStepOther = workstep.errorRemind?.after?.id;
		form.wordsEnd = workstep.errorRemind?.do?.data; // 7
		form.wordsEndVideo = workstep.errorRemind?.do?.video;
	} else {
		form.nextStepOther = workstep.errorRemind?.do?.id;
		form.wordsEndVideo = workstep.errorRemind?.do?.video;
	}
	form.otherTimesMax = workstep.errorRemind?.maximum; // 6
	// noAnswer
	if (workstep.answer[5]?.after) {
		form.wordsNoAnswer = workstep.answer[5]?.do?.data; // 8
		form.wordsNoAnswerVideo = workstep.answer[5]?.do?.video;
	} else if (tts) {
		form.wordsNoAnswerVideo = workstep.answer[5]?.do?.video;
	}
	if (workstep.emptyErrorRemind?.after) {
		form.nextStepNoAnswer = workstep.emptyErrorRemind?.after?.id;
		form.wordsEndNoAnswer = workstep.emptyErrorRemind?.do?.data; // 10
		form.wordsEndNoAnswerVideo = workstep.emptyErrorRemind?.do?.video;
	} else {
		form.nextStepNoAnswer = workstep.emptyErrorRemind?.do?.id;
		form.wordsEndNoAnswerVideo = workstep.emptyErrorRemind?.do?.video;
	}
	form.noAnswerTimesMax = workstep.emptyErrorRemind?.maximum; // 9

	// 智能问答
	form['intelligentReply'] = workstep.intelligentReply;
	form['aiProcessSpeech'] = workstep.intelligentReply.mainProcessSpeech;

	/** 变量存储处理开始 */
	form['aiSpeakVariableId'] = workstep.do.variableId;
	form['aiSpeakVariables'] = workstep.do.variables; //?.filter(item => form['aiSpeak']?.indexOf(`{{${item.name}}}`) !== -1)
	form['aiProcessSpeechVariableId'] = workstep.intelligentReply.variableId;
	form['aiProcessSpeechVariables'] = workstep.intelligentReply.variables;
	form['wordsOtherVariableId'] = workstep.answer[0].do.variableId;
	form['wordsOtherVariables'] = workstep.answer[0].do.variables;
	form['wordsYesVariableId'] = workstep.answer[1].do.variableId;
	form['wordsYesVariables'] = workstep.answer[1].do.variables;
	form['wordsNoVariableId'] = workstep.answer[2].do.variableId;
	form['wordsNoVariables'] = workstep.answer[2].do.variables;
	form['wordsNoAnswerVariableId'] = workstep.answer[5].do.variableId;
	form['wordsNoAnswerVariables'] = workstep.answer[5].do.variables;
	form['wordsEndVariableId'] = workstep.errorRemind.do.variableId;
	form['wordsEndVariables'] = workstep.errorRemind.do.variables;
	form['wordsEndNoAnswerVariableId'] = workstep.emptyErrorRemind.do.variableId;
	form['wordsEndNoAnswerVariables'] = workstep.emptyErrorRemind.do.variables;
	// repeat
	form['repeatAnswers'][0].wordsVariableId = workstep.answer[3].do.variableId;
	form['repeatAnswers'][0].wordsVariables = workstep.answer[3].do.variables;
	form['repeatAnswers'][0].wordsEndVariableId = workstep.repeatErrorRemind.do.variableId;
	form['repeatAnswers'][0].wordsEndVariables = workstep.repeatErrorRemind.do.variables;
	// fuzzy
	form['blurAnswers'][0].wordsVariableId = workstep.answer[4].do.variableId;
	form['blurAnswers'][0].wordsVariables = workstep.answer[4].do.variables;
	form['blurAnswers'][0].wordsEndVariableId = workstep.fuzzyErrorRemind.do.variableId;
	form['blurAnswers'][0].wordsEndVariables = workstep.fuzzyErrorRemind.do.variables;

	/** 变量存储处理结束 */

	/** NLP 存储开始 */
	form['answerYesData'].isAnswerNluLib = workstep.answer[1].enableNluLibrary;
	form['answerYesData'].keys = workstep.answer[1].amendRules || [];

	form['answerYesData'].isOtherNluLib = workstep.answer[1].amendRules?.length > 0;
	if (workstep.answer[1].key.length > 1) {
		form['answerYesData'].nluMark = workstep.answer[1].key[1];
	} else {
		form['answerNoData'].nluMark = workstep.answer[1].key[0];
	}

	form['answerNoData'].isAnswerNluLib = workstep.answer[2].enableNluLibrary;
	form['answerNoData'].keys = workstep.answer[2].amendRules || [];
	form['answerNoData'].isOtherNluLib = workstep.answer[2].amendRules?.length > 0;

	if (workstep.answer[2].key.length > 1) {
		form['answerNoData'].nluMark = workstep.answer[2].key[1];
	} else {
		form['answerNoData'].nluMark = workstep.answer[2].key[0];
	}

	form['answerRepeatData'].isAnswerNluLib = workstep.answer[3].enableNluLibrary;
	form['answerRepeatData'].keys = workstep.answer[3].amendRules || [];
	form['answerRepeatData'].isOtherNluLib = workstep.answer[3].amendRules?.length > 0;

	if (workstep.answer[3].key.length > 1) {
		form['answerRepeatData'].nluMark = workstep.answer[3].key[1];
	} else {
		form['answerRepeatData'].nluMark = workstep.answer[3].key[0];
	}

	form['answerFuzzyData'].isAnswerNluLib = workstep.answer[4].enableNluLibrary;
	form['answerFuzzyData'].keys = workstep.answer[4].amendRules || [];
	form['answerFuzzyData'].isOtherNluLib = workstep.answer[4].amendRules?.length > 0;

	if (workstep.answer[4].key.length > 1) {
		form['answerFuzzyData'].nluMark = workstep.answer[4].key[1];
	} else {
		form['answerFuzzyData'].nluMark = workstep.answer[4].key[0];
	}

	console.warn(workstep.answer, 'initModalData:answer');
	/** NLP 存储结束 */
};
InitModalMethod['messageSure'] = initModalData;

/**
 * 解析表单属性
 * @param { Object } form 表单数据
 * @param { Object } workstep cached的ai工作流
 */
export const parseModalData = (form = {}, workstep = {}, tts = false) => {
	console.log('messageSure', form, workstep);
	if (!form || !workstep || !workstep.do) {
		return;
	}
	workstep.name = form.name;
	workstep.do.data = form['aiSpeak']; // 1
	workstep.do.video = form['aiSpeakVideo'];
	workstep.after.data.speechBeginWaitingTimeMS = form['waitTime']; //2
	// 智能问答
	// workstep.intelligentReply = form['intelligentReply'];
	workstep.intelligentReply = JSON.parse(JSON.stringify(form['intelligentReply']));
	// workstep.intelligentReply.data = form['intelligentReplies'];
	// yes
	if ((form.wordsYes && !tts) || (form.wordsYesVideo && !tts) || (tts && form.wordsYes && form.wordsYesVideo)) {
		workstep.answer[1].do.data = form.wordsYes; // 2
		workstep.answer[1].do.video = form.wordsYesVideo;
		workstep.answer[1].after.id = form.nextStepYes;
		workstep.answer[1].after.no = form.nextStepYes;
	} else {
		workstep.answer[1].do = Object.assign({}, workstep.answer[1].after);
		workstep.answer[1].do.id = form.nextStepYes;
		workstep.answer[1].do.no = form.nextStepYes;
		workstep.answer[1].do.video = form.wordsYesVideo;
		delete workstep.answer[1].after;
	}
	// no
	if ((form.wordsNo && !tts) || (form.wordsNoVideo && !tts) || (tts && form.wordsNo && form.wordsNoVideo)) {
		workstep.answer[2].do.data = form.wordsNo; // 2
		workstep.answer[2].do.video = form.wordsNoVideo;
		workstep.answer[2].after.id = form.nextStepNo;
		workstep.answer[2].after.no = form.nextStepNo;
	} else {
		workstep.answer[2].do = Object.assign({}, workstep.answer[2].after);
		workstep.answer[2].do.id = form.nextStepNo;
		workstep.answer[2].do.no = form.nextStepNo;
		workstep.answer[2].do.video = form.wordsNoVideo;
		delete workstep.answer[2].after;
	}
	// repeat
	if ((form.repeatAnswers[0].words && !tts) || (form.repeatAnswers[0].wordsVideo && !tts) || (tts && form.repeatAnswers[0].words && form.repeatAnswers[0].wordsVideo)) {
		workstep.answer[3].do.data = form.repeatAnswers[0].words; // 3
		workstep.answer[3].do.video = form.repeatAnswers[0].wordsVideo;
	} else {
		workstep.answer[3].do = Object.assign({}, workstep.answer[0].after);
		workstep.answer[3].do.video = form.repeatAnswers[0].wordsVideo;
		delete workstep.answer[3].after;
	}
	if ((form.repeatAnswers[0].wordsEnd && !tts) || (form.repeatAnswers[0].wordsEndVideo && !tts) || (tts && form.repeatAnswers[0].wordsEnd && form.repeatAnswers[0].wordsEndVideo)) {
		workstep.repeatErrorRemind.after.id = form.repeatAnswers[0].nextStep;
		workstep.repeatErrorRemind.after.no = form.repeatAnswers[0].nextStep;
		workstep.repeatErrorRemind.do.data = form.repeatAnswers[0].wordsEnd; // 5
		workstep.repeatErrorRemind.do.video = form.repeatAnswers[0].wordsEndVideo;
	} else {
		workstep.repeatErrorRemind.do = Object.assign({}, workstep.repeatErrorRemind.after);
		workstep.repeatErrorRemind.do.id = form.repeatAnswers[0].nextStep;
		workstep.repeatErrorRemind.do.no = form.repeatAnswers[0].nextStep;
		workstep.repeatErrorRemind.do.video = form.repeatAnswers[0].wordsEndVideo;
		delete workstep.repeatErrorRemind.after;
	}
	workstep.repeatErrorRemind.maximum = form.repeatAnswers[0]?.wordsTimesMax;

	// fuzzy
	if ((form.blurAnswers[0].words && !tts) || (form.blurAnswers[0].wordsVideo && !tts) || (tts && form.blurAnswers[0].words && form.blurAnswers[0].wordsVideo)) {
		workstep.answer[4].do.data = form.blurAnswers[0].words; // 3
		workstep.answer[4].do.video = form.blurAnswers[0].wordsVideo;
	} else {
		workstep.answer[4].do = Object.assign({}, workstep.answer[0].after);
		workstep.answer[4].do.video = form.blurAnswers[0].wordsVideo;
		delete workstep.answer[4].after;
	}
	if ((form.blurAnswers[0].wordsEnd && !tts) || (form.blurAnswers[0].wordsEndVideo && !tts) || (tts && form.blurAnswers[0].wordsEnd && form.blurAnswers[0].wordsEndVideo)) {
		workstep.fuzzyErrorRemind.after.id = form.blurAnswers[0].nextStep;
		workstep.fuzzyErrorRemind.after.no = form.blurAnswers[0].nextStep;
		workstep.fuzzyErrorRemind.do.data = form.blurAnswers[0].wordsEnd; // 5
		workstep.fuzzyErrorRemind.do.video = form.blurAnswers[0].wordsEndVideo;
	} else {
		workstep.fuzzyErrorRemind.do = Object.assign({}, workstep.fuzzyErrorRemind.after);
		workstep.fuzzyErrorRemind.do.id = form.blurAnswers[0].nextStep;
		workstep.fuzzyErrorRemind.do.no = form.blurAnswers[0].nextStep;
		workstep.fuzzyErrorRemind.do.video = form.blurAnswers[0].wordsEndVideo;
		delete workstep.fuzzyErrorRemind.after;
	}
	workstep.fuzzyErrorRemind.maximum = form.blurAnswers[0]?.wordsTimesMax; // 4
	// other
	if ((form.wordsOther && !tts) || (form.wordsOtherVideo && !tts) || (tts && form.wordsOther && form.wordsOtherVideo)) {
		workstep.answer[0].do.data = form.wordsOther; // 3
		workstep.answer[0].do.video = form.wordsOtherVideo;
	} else {
		workstep.answer[0].do = Object.assign({}, workstep.answer[0].after);
		workstep.answer[0].do.video = form.wordsOtherVideo;
		delete workstep.answer[0].after;
	}
	if ((form.wordsEnd && !tts) || (form.wordsEndVideo && !tts) || (tts && form.wordsEnd && form.wordsEndVideo)) {
		workstep.errorRemind.after.id = form.nextStepOther;
		workstep.errorRemind.after.no = form.nextStepOther;
		workstep.errorRemind.do.data = form.wordsEnd; // 5
		workstep.errorRemind.do.video = form.wordsEndVideo;
	} else {
		workstep.errorRemind.do = Object.assign({}, workstep.errorRemind.after);
		workstep.errorRemind.do.id = form.nextStepOther;
		workstep.errorRemind.do.no = form.nextStepOther;
		workstep.errorRemind.do.video = form.wordsEndVideo;
		delete workstep.errorRemind.after;
	}
	workstep.errorRemind.maximum = form.otherTimesMax; // 4
	// noAnswer
	if ((form.wordsNoAnswer && !tts) || (form.wordsNoAnswerVideo && !tts) || (tts && form.wordsNoAnswer && form.wordsNoAnswerVideo)) {
		workstep.answer[5].do.data = form.wordsNoAnswer; // 3
		workstep.answer[5].do.video = form.wordsNoAnswerVideo;
	} else {
		workstep.answer[5].do = Object.assign({}, workstep.answer[5].after);
		workstep.answer[5].do.video = form.wordsNoAnswerVideo;
		delete workstep.answer[5].after;
	}
	if ((form.wordsEndNoAnswer && !tts) || (form.wordsEndNoAnswerVideo && !tts) || (tts && form.wordsEndNoAnswer && form.wordsEndNoAnswerVideo)) {
		workstep.emptyErrorRemind.after.id = form.nextStepNoAnswer;
		workstep.emptyErrorRemind.after.no = form.nextStepNoAnswer;
		workstep.emptyErrorRemind.do.data = form.wordsEndNoAnswer; // 5
		workstep.emptyErrorRemind.do.video = form.wordsEndNoAnswerVideo;
	} else {
		workstep.emptyErrorRemind.do = Object.assign({}, workstep.emptyErrorRemind.after);
		workstep.emptyErrorRemind.do.id = form.nextStepNoAnswer;
		workstep.emptyErrorRemind.do.no = form.nextStepNoAnswer;
		workstep.emptyErrorRemind.do.video = form.wordsEndNoAnswerVideo;
		delete workstep.emptyErrorRemind.after;
	}
	workstep.emptyErrorRemind.maximum = form.noAnswerTimesMax; // 4

	// workstep.answer[1].do.data = form['wordsYes']; // 3
	// workstep.answer[1].after.id = form['nextStepYes']; // 4
	// workstep.answer[2].do.data = form['wordsNo'];
	// workstep.answer[2].after.id = form['nextStepNo'];
	// workstep.answer[0].do.data = form['wordsOther'];
	// workstep.errorRemind.maximum = form['otherTimesMax'];
	// workstep.errorRemind.after.id = form['nextStepOther'];
	// workstep.errorRemind.do.data = form['wordsEnd'];
	// workstep.answer[3].do.data = form['wordsNoAnswer'];
	// workstep.emptyErrorRemind.after.id = form['nextStepNoAnswer'];
	// workstep.emptyErrorRemind.maximum = form['noAnswerTimesMax'];
	// workstep.emptyErrorRemind.do.data = form['wordsEndNoAnswer'];

	/** 预录制 TTS 视频处理开始 */
	// workstep.answer[1].do.video = form['wordsYesVideo'];
	// workstep.answer[2].do.video = form['wordsNoVideo'];
	// workstep.answer[0].do.video = form['wordsOtherVideo'];
	// workstep.errorRemind.do.video = form['wordsEndVideo'];
	// workstep.answer[3].do.video = form['wordsNoAnswerVideo'];
	// workstep.emptyErrorRemind.do.video = form['wordsEndNoAnswerVideo'];
	/** 预录制 TTS 视频处理结束 */

	/** 变量存储处理开始 */
	workstep.do.variableId = form['aiSpeakVariableId'];
	workstep.do.variables = form['aiSpeakVariables']; //?.filter(item => form['aiSpeak'].indexOf(`{{${item.name}}}`) !== -1)
	workstep.intelligentReply.variableId = form['aiProcessSpeechVariableId'];
	workstep.intelligentReply.variables = form['aiProcessSpeechVariables'];
	workstep.answer[0].do.variableId = form['wordsOtherVariableId'];
	workstep.answer[0].do.variables = form['wordsOtherVariables'];
	workstep.answer[1].do.variableId = form['wordsYesVariableId'];
	workstep.answer[1].do.variables = form['wordsYesVariables'];
	workstep.answer[2].do.variableId = form['wordsNoVariableId'];
	workstep.answer[2].do.variables = form['wordsNoVariables'];
	workstep.answer[3].do.variables = form.repeatAnswers[0]?.wordsVariables;
	workstep.answer[3].do.variableId = form.repeatAnswers[0]?.wordsVariableId;
	workstep.answer[4].do.variableId = form.blurAnswers[0]?.wordsVariableId;
	workstep.answer[4].do.variables = form.blurAnswers[0]?.wordsVariables;
	workstep.answer[5].do.variableId = form['wordsNoAnswerVariableId'];
	workstep.answer[5].do.variables = form['wordsNoAnswerVariables'];
	workstep.errorRemind.do.variableId = form['wordsEndVariableId'];
	workstep.errorRemind.do.variables = form['wordsEndVariables'];
	workstep.emptyErrorRemind.do.variableId = form['wordsEndNoAnswerVariableId'];
	workstep.emptyErrorRemind.do.variables = form['wordsEndNoAnswerVariables'];

	workstep.repeatErrorRemind.do.variableId = form.repeatAnswers[0]?.wordsEndVariableId;
	workstep.repeatErrorRemind.do.variables = form.repeatAnswers[0]?.wordsEndVariables;
	workstep.fuzzyErrorRemind.do.variableId = form.blurAnswers[0]?.wordsEndVariableId;
	workstep.fuzzyErrorRemind.do.variables = form.blurAnswers[0]?.wordsEndVariables;
	/** 变量存储处理结束 */

	/** NLP 存储开始 */
	workstep.answer[1].enableNluLibrary = form['answerYesData'].isAnswerNluLib;
	if (form['answerYesData'].keys.length > 0 && form['answerYesData'].isOtherNluLib) {
		workstep.answer[1].amendRules = form['answerYesData'].keys;
	} else {
		workstep.answer[1].amendRules = [];
	}

	if (workstep.answer[1].key[0] !== form['answerYesData'].nluMark) {
		workstep.answer[1].key.push(form['answerYesData'].nluMark);
	}
	workstep.answer[2].enableNluLibrary = form['answerNoData'].isAnswerNluLib;
	if (form['answerNoData'].keys.length > 0 && form['answerNoData'].isOtherNluLib) {
		workstep.answer[2].amendRules = form['answerNoData'].keys;
	} else {
		workstep.answer[2].amendRules = [];
	}

	if (workstep.answer[2].key[0] !== form['answerNoData'].nluMark) {
		workstep.answer[2].key.push(form['answerNoData'].nluMark);
	}

	workstep.answer[3].enableNluLibrary = form['answerRepeatData'].isAnswerNluLib;
	if (form['answerRepeatData'].keys.length > 0 && form['answerRepeatData'].isOtherNluLib) {
		workstep.answer[3].amendRules = form['answerRepeatData'].keys;
	} else {
		workstep.answer[3].amendRules = [];
	}
	if (workstep.answer[3].key[0] !== form['answerRepeatData'].nluMark) {
		workstep.answer[3].key.push(form['answerRepeatData'].nluMark);
	}
	workstep.answer[4].enableNluLibrary = form['answerFuzzyData'].isAnswerNluLib;
	if (form['answerFuzzyData'].keys.length > 0 && form['answerFuzzyData'].isOtherNluLib) {
		workstep.answer[4].amendRules = form['answerFuzzyData'].keys;
	} else {
		workstep.answer[4].amendRules = [];
	}

	if (workstep.answer[4].key[0] !== form['answerFuzzyData'].nluMark) {
		workstep.answer[4].key.push(form['answerFuzzyData'].nluMark);
	}

	/** NLP 存储结束 */
	workstep.name = form.name;

	if (workstep.repeatErrorRemind && !(workstep.repeatErrorRemind?.after?.id || workstep.repeatErrorRemind?.do?.id)) {
		workstep.answer.splice(
			workstep.answer.findIndex(item => item.type === 'repeat'),
			1
		);
		console.warn(
			workstep.answer.findIndex(item => item.type === 'repeat'),
			'repeat:'
		);
	}

	if (workstep.fuzzyErrorRemind && !(workstep.fuzzyErrorRemind?.after?.id || workstep.fuzzyErrorRemind?.do?.id)) {
		workstep.answer.splice(
			workstep.answer.findIndex(item => item.type === 'fuzzy'),
			1
		);
		console.warn(
			workstep.answer.findIndex(item => item.type === 'fuzzy'),
			'fuzzy:'
		);
	}

	console.log('parseModalDataAnswer: ', workstep.answer);
};
ParseModalMethod['messageSure'] = parseModalData;

// {
//     "needHearing": "",
//     "robotProperty": {
//         "needHearing": true,
//         "videoType": "",
//         "audioType": ""
//     },
//     "name": "",
//     "do": {
//         "data": "1",
//         "command": "speak",
//         "variables": [],
//         "variableId": ""
//     },
//     "no": "messageSure_1",
//     "id": "messageSure_1",
//     "type": "messageSure",
//     "after": {
//         "data": {
//             "judgmentType": "positive-negative",
//             "speechBeginWaitingTimeMS": 2
//         },
//         "command": "listen"
//     },
//     "intelligentReply": {
//         "isOn": true,
//         "data": [
//             {
//                 "name": "who",
//                 "reply": "回复"
//             },
//             {
//                 "name": "repeat",
//                 "reply": "回复"
//             }
//         ],
//         "mainProcessSpeech": "{{name}}",
//         "speechBeginWaitingTimeMS": 2,
//         "variables": [
//             {
//                 "initMode": "non-init",
//                 "name": "name",
//                 "url": "",
//                 "method": "",
//                 "params": "",
//                 "dataMasking": null
//             }
//         ],
//         "variableId": 312
//     },
//     "answer": [
//         {
//             "do": {
//                 "command": "listen"
//             },
//             "key": "others",
//             "type": "other"
//         },
//         {
//             "do": {
//                 "data": "{{name}}",
//                 "command": "speak",
//                 "variables": [
//                     {
//                         "initMode": "non-init",
//                         "name": "name",
//                         "url": "",
//                         "method": "",
//                         "params": "",
//                         "dataMasking": null
//                     }
//                 ],
//                 "variableId": 312
//             },
//             "key": "positive",
//             "enableNluLibrary": true,
//             "amendRules": [],
//             "type": "yes",
//             "after": {
//                 "command": "jump-to",
//                 "no": "BlankNode_2",
//                 "id": "BlankNode_2"
//             }
//         },
//         {
//             "do": {
//                 "command": "jump-to",
//                 "no": "BlankNode_3",
//                 "id": "BlankNode_3"
//             },
//             "key": "negative",
//             "enableNluLibrary": true,
//             "amendRules": [],
//             "type": "no"
//         },
//         {
//             "key": "empty",
//             "do": {
//                 "data": {
//                     "judgmentType": "positive-negative",
//                     "speechBeginWaitingTimeMS": 3000
//                 },
//                 "command": "listen"
//             }
//         }
//     ],
//     "errorRemind": {
//         "do": {
//             "command": "jump-to",
//             "no": "BlankNode_4",
//             "id": "BlankNode_4"
//         },
//         "maximum": 3
//     },
//     "emptyErrorRemind": {
//         "do": {
//             "command": "jump-to",
//             "id": "BlankNode_5",
//             "no": "BlankNode_5"
//         },
//         "maximum": "4",
//         "type": "noAnswers"
//     },
//     "completed": true,
//     "hasStartNode": false
// }
